package cool.taomu.test

import cool.taomu.entity.DataEntity
import cool.taomu.entity.DataEntity.LanguageType
import cool.taomu.thread.NetworkThread
import cool.taomu.utils.ThriftUtils
import java.io.File
import java.nio.ByteBuffer
import org.apache.commons.io.FileUtils
import org.apache.commons.lang3.SerializationUtils

class TaomuExecuteTest {
	def static void main(String[] args) {
		var String code = FileUtils.readFileToString(new File("./usecase/Demo.groovy"),"UTF-8");
		var host = "192.168.1.200";
		var port = 8090;
		val data = new DataEntity();
		data.type = LanguageType.GROOVY;
		data.main_class = "demo.Demo";
		data.payload = code
		ThriftUtils.rpc(host, port, [
			var NetworkThread.Client client = new NetworkThread.Client(it);
			client.execute(ByteBuffer.wrap(SerializationUtils.serialize(data)));
		])
	}
}
